﻿/**
 * http://vkontakte.ru/app1850321_355679
 * @author Артём Григорьев
 * @author Иннокентий Шувалов
 */

package ;

import client.Channel;
import client.INews;
import flash.display.Sprite;
import flash.Lib;
import gui.hug.HUGSprite;
import gui.hug.HUGTabbedPanel;
import gui.hug.LightButton;
import gui.hug.HUGColors;
import gui.hug.Tab;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import tab.CategoriesTab;
import tab.FindTag;

import tab.MainTab;
import tab.ChannelsTab;
import tab.ItemsTab;

import list.NewList;

import loader.Loader;

class Application extends Sprite
{

	private var viewerId 	: Int;
	private var tabbedPanel : HUGTabbedPanel;
	
	public function new() 
	{
		super();
		Lib.current.addChild(this);
		tabbedPanel = new HUGTabbedPanel(607);
		this.addChild(tabbedPanel);
		
		var params : Dynamic<String> = flash.Lib.current.loaderInfo.parameters;
		viewerId = (params.viewer_id == null) ? 0 : Std.parseInt(params.viewer_id);	
		
		this.addMainTab(viewerId);
		
		tabbedPanel.addTab(new ChannelsTab(tabbedPanel, viewerId));
		tabbedPanel.addTab(new ItemsTab(1, "sports.ru", tabbedPanel, viewerId));
		tabbedPanel.addTab(new CategoriesTab(tabbedPanel, viewerId));
		tabbedPanel.addTab(new FindTag(tabbedPanel, viewerId));
	}
	
	public function addMainTab(uid : Int)
	{
		tabbedPanel.addTab(new MainTab(tabbedPanel, uid));
	}
	
	
	public function addTab(sprite : HUGSprite, name : String)
	{
		var tab = new Tab(sprite, name);
		tabbedPanel.addTab(tab);
	}
	
	public function onKeyDown ( e : KeyboardEvent ) {
	/*	switch (e.keyCode) {
			case Keyboard.ENTER : {
			
				// Кекс, разберись с getItem!!!!! (Тёма)
				addTab(new HUGSprite(), newsList.getItem().getName());
			}
			case Keyboard.F5 : {
				tabbedPanel.draw();
			}
		} */
	}
	
}